Dukascopy Support Board http://www.dukascopy.com/swiss/english/forex/jforex/forum/ |
|
Only one open order at time. Please help. http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=57744 |
Page 1 of 1 |
Author: | NightOwl [ Sat 20 Nov, 2021, 16:45 ] |
Post subject: | Only one open order at time. Please help. |
Hello, how can I limit my orders to only one order at a time? |
Author: | goose_ [ Sun 21 Nov, 2021, 12:18 ] |
Post subject: | Re: Only one open order at time. Please help. |
Maybe something like this. Create global variable, like counter. In function onBar for example use period object to generate "interrupt" for a given interval. In this example code I use One_hour period, it means strategy in every hour will execute the code in this conditional statement. And then you can reset the timer, counters etc in other period like DAILY. Next you can create function sendOrder and in body this function check value of counter. Something like that... import java.util.Random; You can use onTick function to increment counter etc. For example in every 500 ticks counter has reset public void onTick(Instrument instrument, ITick tick) throws JFException { |
Author: | NightOwl [ Sun 21 Nov, 2021, 14:17 ] |
Post subject: | Re: Only one open order at time. Please help. |
Thank you goose_ for your answer. I have experience in systems that count to a limit and reset. Now I am looking for a system that makes an order and then checks if there is any open orders, and if there are no open orders, then it will open an order again. I have poor coding skills. OnBar: >OPEN ORDER WITH SL/TP >CHECK IF ORDER IS STILL OPEN >IF NO OPEN ORDER THEN OPEN NEW ORDER I am looking at https://www.dukascopy.com/client/javadoc/ and asking this forum for help. Thank you. |
Author: | goose_ [ Sun 21 Nov, 2021, 20:06 ] |
Post subject: | Re: Only one open order at time. Please help. |
To check if there is no open orders is method engine.getOrders() https://www.dukascopy.com/client/javado ... ngine.html This is na array. Examples how to use arraylist https://beginnersbook.com/2013/12/java-arraylist/ how it works. If You send order then this IOrder object is store to this array. And You can read this array using .size() method to verified is there any orders opened, any object in there. If You put something to array, ten array's size increase. And this method is how to track if there's any order opened right know. engine.getOrders() track current opened order, but there is also a method context.getHistory().getOrderHistory to get list of closed orders https://www.dukascopy.com/wiki/en/devel ... er-history package jforex; |
Author: | NightOwl [ Tue 30 Nov, 2021, 18:58 ] |
Post subject: | Re: Only one open order at time. Please help. |
Hey and thank you goose_ for your excelent answer! Now can you pretty please make it such that it both sells ands buys? Thank you! |
Author: | NightOwl [ Sat 25 Dec, 2021, 09:16 ] |
Post subject: | Re: Only one open order at time. Please help. |
Hello goose_ You are amazing at coding! Can you make this so that it goes BUY, SELL, BUY, SELL... infinite ? That would be super ...and if it is not too hard, make it please so that it has stop loss and take profit and a time out when the order gets closed. Thanks you are the superb! Then I can close this as solved. |
Page 1 of 1 |