Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hi i want to make a strategy in easylanguage that would be triggered based on an indicator, then enter a limit order to short on the next candle, at a fixed amount away from this candle's high. i also want to risk off the high of this candle. below are two of my attempts at the code:
If marketposition = 0 then begin
If tigger > tiggeramount then
sellshort ("enter short") 1000 shares next bar at (high - offthehigh) limit;
Buytocover ("exit stop") 1000 shares next bar At (high) stop;
end;
If marketposition = -1 then begin
Buytocover ("exit profit") 1000 shares next bar At (entryprice - offtheentry) limit;
end;
this one for some reason randomly gets rid of my stop order sometimes, leaving me with unlimited risk.....
If marketposition = 0 then begin
If tigger > tiggeramount then
sellshort ("enter short") 1000 shares next bar at (high - offthehigh) limit;
end;
If marketposition = -1 then begin
Buytocover ("exit stop") 1000 shares next bar At (entryprice + offthehigh) stop;
Buytocover ("exit profit") 1000 shares next bar At (entryprice - offtheentry) limit;
end;
this one only makes a stop order AFTER the candle that i got in on had closed. what if i got in and the candle closed much higher than the amount /share i wanted to risk? it doesnt make sense either.
how do i make this work?
Can you help answer these questions from other members on NexusFi?
your first code only issues the stop while you are flat i.e. once you are in a position the stop would not be issued anymore.
Without intrabar order generation your second code snippet will only be aware of the fill at the end of the entry bar and issue the stop for the next bar then.
You could for example store the high of a bar within a variable while you are flat and issue the stop order unconditionally using this variable as stop price.
Regards,
ABCTG
cong93
toronto, canada
Posts: 2 since Mar 2019
Thanks Given: 0
Thanks Received: 0
Hi ABCTG I tried to do that by adding in a variable to equal the “high” while the position was flat, then set the stop order to that variable, however I think that variable’s value seem to change to the high of every single closed candle afterwards and constantly moving my stop to the previous candles high
i tried the intrabar generation, that seems to also mess up my indicator's calculation and cause me to take trades where i wouldnt want to.
another solution i can think of might be to make a loop to increase the index of the high which each new candle, high[1] then high[2], high[3]... and refer back to that candle. but that could be a problem if for example i have an order out to short, and it fills me 3 candles after, then id have to start counting from high[2], so id also have to check where i got filled.
this seems like a lot of work for a very simple task with easylanguage. there must be an easier way
ABCTG
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623
Hi cong93,
it sounds like your code also allowed updating the variable while you are in a position, but without seeing the code this is just a guess.