NexusFi: Find Your Edge


Home Menu

 





problem with stop order in easylanguage


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,617 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
 

problem with stop order in easylanguage

 
cong93
toronto, canada
 
Posts: 2 since Mar 2019
Thanks Given: 0
Thanks Received: 0

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?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Exit Strategy
NinjaTrader
Futures True Range Report
The Elite Circle
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
 
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623


Hi cong93,

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

Follow me on Twitter
 
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   is a Vendor
 
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.

Regards,

ABCTG


cong93 View Post
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.
another solution i can think of might be to make a loop to increase the index of the high which each new candle, 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. 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


Follow me on Twitter

 



Last Updated on March 7, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts