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,621 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #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?
$4.5M Floods Russia Nuclear Contract in 24 Hours -- Krem …
Prediction Markets & Event Contracts
Warsh Rate Hike at 40%, Iran June 15 Expires Tonight at …
Prediction Markets & Event Contracts
CME Group CEO Calls CFTC-Approved Crypto Perps Dangerous …
Traders Hideout
Roland Garros Final Day: $3M on Zverev at 80.5% -- Leban …
Prediction Markets & Event Contracts
Wood Mackenzie Drops $200 Oil Forecast -- Airspace Expir …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 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


© 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