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,026 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

(login for full post details)
  #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
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Request for MACD with option to use different MAs for fa …
NinjaTrader
Trader Dale [email protected] or Scammer Dale
Trading Reviews and Vendors
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Tao te Trade: way of the WLD
30 thanks
Supertradersams Thread Journal on NQ/MNQ
25 thanks
Deaddogs Stock Trading
23 thanks
GFIs1 1 DAX trade per day journal
22 thanks
Daytrading ES & NQ
13 thanks

(login for full post details)
  #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
The following 2 users say Thank You to Lampert for this post:
(login for full post details)
  #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
The following user says Thank You to tradersheldon for this post:





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