NexusFi: Find Your Edge


Home Menu

 





Gaps trading with EasyLanguage


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Saturnix with 2 posts (0 thanks)
    2. looks_two ABCTG with 2 posts (2 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Waldemar with 1 posts (1 thanks)
    1. trending_up 2,770 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
Saturnix
milano, italy
 
Posts: 4 since Feb 2019
Thanks Given: 1
Thanks Received: 0

I'd like to code a very simple strategy: daily candles, if market opened with at least a -0.5 gap from previous close, buy and place a sell order at whatever price it closed yesterday.

Unfortunately, I have no idea on how to code it.

 
Code
                            
[IntrabarOrderGeneration true]

Value1 CloseD(1);
Value2 OpenD(0);

// Gap down > 0.5
Condition1 = (Value1 Value2) > 0.5 ;

if 
Condition1 then
    Buy 
("Gap down"this bar;
    
Sell ("Gap fill"this bar at Value1 limit
How can I place a Sell order at Value1 limit on the same bar? This is not allowed, since "you cannot place limit orders on the same bar".

Should I move the chart to minute instead of daily?

Or should I use setprofittarget? I'd like to use it, but it wants profit in $ value, while I only know the price I want to sell at, not which profit I'd make with it.

Many thanks!


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
June 15 Peace Odds Surge From 3.6% to 12.25% After Trump …
Prediction Markets & Event Contracts
Fabrication or Framework? Irans Denied MOU Explains the …
Prediction Markets & Event Contracts
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
CFTC Approves First US Bitcoin Perpetual Futures -- Kals …
Traders Hideout
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642


Hi Saturnix,

you would have to issue your limit exit order using "next bar" within the order command, but you could accomplish what you have in mind by storing the exit price in a variable while you are flat and then use the variable within your exit order.

Regards,

ABCTG


Follow me on X Reply With Quote
Thanked by:
  #4 (permalink)
Saturnix
milano, italy
 
Posts: 4 since Feb 2019
Thanks Given: 1
Thanks Received: 0


ABCTG View Post
Hi Saturnix,

you would have to issue your limit exit order using "next bar" within the order command, but you could accomplish what you have in mind by storing the exit price in a variable while you are flat and then use the variable within your exit order.

Regards,

ABCTG

Thanks for your input!

I don't understand: I already have the exit price in a variable (Value1). The problem is that I can only sell at that price at next bar, not on this bar.


Reply With Quote
  #5 (permalink)
 Waldemar 
Toronto
 
Experience: Intermediate
Platform: Multicharts
Trading: GC, CL, Currency Futures
Posts: 3 since Mar 2019
Thanks Given: 41
Thanks Received: 1


Saturnix View Post
Should I move the chart to minute instead of daily?


Yes, go intraday, easy solution.
If you don't have intraday data, this strategy is so easy that you can program it in excel, for which you definitely have data. And Excel doesn't forbid you to enter on the same bar.

What you are trying to do is the same thing that this "the gap guy" Scott Andrews did. Check him out, if you didn't.

My 0.02




Sent using the NexusFi mobile app


Reply With Quote
Thanked by:
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

Saturnix,

you are welcome. The idea is that you only update the variable when you are flat and issue the order unconditionally using the "next bar" command.
On top of that you could most likely get rid of intrabar order generation completely in this case and use the "Open next bar" syntax for your entry. This thread should get you going:
https://community.tradestation.com/discussions/Topic_Archive.aspx?Topic_ID=43394

Regards,

ABCTG


Saturnix View Post
Thanks for your input!

I don't understand: I already have the exit price in a variable (Value1). The problem is that I can only sell at that price at next bar, not on this bar.


Follow me on X Reply With Quote
Thanked by:




Last Updated on March 26, 2019


© 2026 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 - Downloads - Top
no new posts