NexusFi: Find Your Edge


Home Menu

 





how to buy/sell if market is +5/-5 at exact time


Discussion in EasyLanguage Programming

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




 
Search this Thread

how to buy/sell if market is +5/-5 at exact time

  #1 (permalink)
 tradersheldon 
Western Maryland
 
Experience: Intermediate
Platform: Multicharts
Broker: Vision Financial (Direct)/ CQG, Rithmic
Trading: Gold, Euro, ES
Posts: 39 since Sep 2010
Thanks Given: 20
Thanks Received: 50

I need help to code a particular setup:

if price is +5 from previous session close at 2000 (8 pm) then buy at market

or

if price is -5 from previous session close at 2000 (8 pm) then sellshort at market



I can enter this trading condition into a complete system, but am having trouble getting the right code for this.
Thanks for any help.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Better Renko Gaps
The Elite Circle
Futures True Range Report
The Elite Circle
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
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
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #3 (permalink)
 
Lampert's Avatar
 Lampert 
Calgary, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: IB, IQFeed
Trading: GC
Posts: 76 since Nov 2011
Thanks Given: 73
Thanks Received: 142



tradersheldon View Post
I need help to code a particular setup:

if price is +5 from previous session close at 2000 (8 pm) then buy at market

or

if price is -5 from previous session close at 2000 (8 pm) then sellshort at market

Sheldon - Here is some code that should do what you want. I added times to exit the position also. If you need more, perhaps you could provide additional details like the instrument and the bar type.

Len

 
Code
[IntrabarOrderGeneration = True]

Variables:
	ClosePrice (Close) ,
	OncePerDay     (1) ;

If Time = 2000 then begin
	OncePerDay = 0 ;
	ClosePrice = Close ;
end ;
 
If Close >= ClosePrice + 5 and Time < 1800 and OncePerDay = 0 then begin
	OncePerDay = 1 ;
	Buy next bar at open ;
end ;
 
If Close <= ClosePrice - 5 and Time < 1800 and OncePerDay = 0 then begin
	OncePerDay = 1 ;
	Sellshort next bar at open ;
end ;
 
If MarketPosition = 1 and Time > 1900 then sell next bar at open ;

If MarketPosition = -1 and Time > 1900 then buytocover next bar at open ;

Reply With Quote
Thanked by:
  #4 (permalink)
 tradersheldon 
Western Maryland
 
Experience: Intermediate
Platform: Multicharts
Broker: Vision Financial (Direct)/ CQG, Rithmic
Trading: Gold, Euro, ES
Posts: 39 since Sep 2010
Thanks Given: 20
Thanks Received: 50


Lampert View Post
Sheldon - Here is some code that should do what you want. I added times to exit the position also. If you need more, perhaps you could provide additional details like the instrument and the bar type.

Len

 
Code
[IntrabarOrderGeneration = True]

Variables:
	ClosePrice (Close) ,
	OncePerDay     (1) ;

If Time = 2000 then begin
	OncePerDay = 0 ;
	ClosePrice = Close ;
end ;
 
If Close >= ClosePrice + 5 and Time < 1800 and OncePerDay = 0 then begin
	OncePerDay = 1 ;
	Buy next bar at open ;
end ;
 
If Close <= ClosePrice - 5 and Time < 1800 and OncePerDay = 0 then begin
	OncePerDay = 1 ;
	Sellshort next bar at open ;
end ;
 
If MarketPosition = 1 and Time > 1900 then sell next bar at open ;

If MarketPosition = -1 and Time > 1900 then buytocover next bar at open ;



Thanks alot! That was enough for me to get started. I got my program finished now.
Sheldon

Started this thread Reply With Quote
Thanked by:




Last Updated on June 14, 2012


© 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