Hi, I need help, I’m working on a robot, the one I copy next. It is the break in the dax of the first 15 minutes of the day. But I need you not to be continuously buying and selling, I only try 2 times a day, once in purchase and another one for sale if the price touches. how can I do it? thank you
Defparam cumulateorders = false
Defparam flatafter = 171500
n=1
// nos quedamos a las 9.15 con el maximo y minimo de 1 vela antes, es decir, la vela de 9 a 9.15, calculamos la amplitud de esa vela
IF Time = 091500 THEN
maximo = highest[1](high)
minimo = lowest[1](low)
compra = 1
venta = 1
ENDIF
if Time > 091500 AND Time <= 171500 THEN
IF compra = 1 THEN
buy n contracts at maximo stop
ENDIF
IF venta = 1 THEN
sellshort n contracts at minimo stop
ENDIF
ENDIF
If longonmarket THEN
compra = 0
ENDIF
IF shortonmarket THEN
venta = 0
ENDIF
set stop ploss 10
set target pprofit 15
If you are on market you are already tagging your 2 variables at lines 26 and 30, so their tests at lines 15 and 19 should already work.
If it works, it works. But what happens is that he spends all day doing operations. And I want you to only put one to buy and one to sell at the most. Although the condition is returned, if it has already bought once, do not buy again that day.
When using pending orders, they can trigger anytime between 2 bars at the price level we put them on. So, we never know when they are executed, and if they last only 0 bar (open and close inside the bar), there is no way to know we were on market inside this bar, that’s why you have a lot of trades because your ‘compra’ and ‘venta’ variables will never be set to 1.
in pdf of probuilder of prorealtime there is a code very good , page 80 i think .
Hello, I already tried it, but when you change the stop by 10 and put a take of 10, it happens again, spend the day getting operations, I want you to schedule a purchase operation at the maximum and a sale in The minimum and that throughout the day if the price touches it will execute one or both. And not to continue scheduling all day orders.
Sorry but the code i gave here , only take 2 orders max in one day .Sometimes no orders .
maybe your code is different . To solve your problem you have just to implement a counter , with reset for a new day ….
hope that helps .
DEFPARAM CUMULATEORDERS = false
DEFPARAM FLATBEFORE = 080000
DEFPARAM FLATAFTER = 171500
Position = 1
if intradaybarindex=0 then
count = 0
lastindex = 0
endif
IF Time = 081000 THEN
haut = highest[2](high)
bas = lowest[2](low)
amplitude = haut - bas
ENDIF
IF TIME > 081000 AND TIME <= 170000 THEN
//Conditions pour ouvrir une position acheteuse
IF your conditionsTHEN
BUY Position contracts at haut stop
ENDIF
If longonmarket AND TRADEINDEX<>lastindex THEN
COUNT = COUNT+1
Lastindex = TRADEINDEX
ENDIF
//Conditions pour ouvrir une position vendeuse
IF yourconditionsTHEN
SELLSHORT Position contracts at bas stop
ENDIF
IF shortonmarket AND TRADEINDEX<>lastindex THEN
COUNT = COUNT+1
Lastindex = TRADEINDEX
ENDIF
//stops et Objectifs
SET STOP LOSS 31
SET TARGET PROFIT 23
ENDIF
if you want to have one sell and one buy
if INTRADAYBARINDEX =0 THEN
COUNTBUY =0
COUNTSELL =0
LASTINDEX = 0
ENDIF
etc etc etc
Is the same code that I put take of 10 and stop of 10. in the original code, has no take and ends at the end of the day, and has a large stop. Would you know how to do the meter and reset it the next day?