NexusFi: Find Your Edge


Home Menu

 




TS with grid orders in EasyLanguage


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one mwtzzz with 2 posts (0 thanks)
    2. looks_two Dan46 with 2 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 OMEGAA with 1 posts (0 thanks)
    1. trending_up 3,023 views
    2. thumb_up 0 thanks given
    3. group 4 followers
    1. forum 6 posts
    2. attach_file 0 attachments




Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now, It is Free
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.

-- Big Mike, Site Administrator

Available coupon codes for premium Elite Membership:
  • If you are a researcher and pay attention to details, you qualify for our 10% discount - "CHARTIST"
  • If you are a veteran or in public/community service, you qualify for 15% discount - "PURPLECHART"
  • If you are 60+ years old, you qualify for our 20% discount - "WISDOM"
  • Discounts are based on the honor system. If we can't trust you to do the right thing, please move along.

(If you already have an account, login at the top of the page)

 
Search this Thread

TS with grid orders in EasyLanguage

(login for full post details)
  #1 (permalink)
Dan46
Milan Italy
 
Posts: 2 since Feb 2013
Thanks Given: 0
Thanks Received: 0

Hi guys, I’m quite new to programming and need some help for a system I’m trying to code.

I want the TS to buy at MovingAverage – X points (first trade).
Then buy every time the price drops Y points following a “grid style”.

Example:
X = 40
Y = 30
Moving average @ 240
First buy limit @ 200
Second buy limit @ 170
Third buy limit @ 140
4th buy limit @ 110
5th buy limit @ 80
6th….

And close all open positions once the price touch the MovingAverage.


This is the code I tried to write:

 
Code
inputs: Len(100), X(40), Y(30);
vars: entrylevel(0), previouslevel(0), nextlevel(0);

//first entry
If marketposition = 0 then begin
entrylevel = Average(Close, Len)- X;
buy next bar at entrylevel limit;
end;

//next entries
If marketposition > 0 and currentshares > 0 then begin
   If currentshares>currentshares[1] then previouslevel=minlist(open, nextlevel,entrylevel);
   nextlevel=previouslevel-Y;
end;

if mp>0 then buy next bar at nextlevel limit;

//exit
if marketposition > 0 then sell next bar at Average(Close, Len ) limit;
The problems I find are:
1) The levels aren’t always respected (honestly I can’t understand why sometime the levels are correct and sometime not)
2) In this way (next bar limit) the orders are executed no more than once per bar, even if a single bar drop more than Y points (that would mean more than a single trade per bar)

Can you guys please help me with this code?
Thank you in advance

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ninzaco snow eagle trading
NinjaTrader
VolumenStop V7 Ninja Trader 8
NinjaTrader
Actual code for RSI using Wilders average, not the canne …
ThinkOrSwim
RangeDisparityMeter Indicator for NT8
Platforms and Indicators
Strategy: second data series for using correct entry tim …
NinjaTrader
 

(login for full post details)
  #3 (permalink)
mwtzzz
Sunnyvale, CA
 
Posts: 171 since Dec 2012
Thanks Given: 8
Thanks Received: 107


The limit order tells it to buy at that price or better, so are you sure the discrepensy isn't just a reflection of getting it at a better price?

Reply With Quote
(login for full post details)
  #4 (permalink)
Dan46
Milan Italy
 
Posts: 2 since Feb 2013
Thanks Given: 0
Thanks Received: 0


mwtzzz View Post
The limit order tells it to buy at that price or better, so are you sure the discrepensy isn't just a reflection of getting it at a better price?

hi mwtzzz, I think I can exclude that the different levels the TS buys are due to better price fills because it happens for example that the TS buys few candles after the candle that closed under the theoretical price to buy..

example: the TS bought at 130, next theoretical price to buy is 100
it happens that there are candles that close at let's say 95 and the TS still don't buys the next contract...

(sorry for my bad english)

Reply With Quote
(login for full post details)
  #5 (permalink)
mwtzzz
Sunnyvale, CA
 
Posts: 171 since Dec 2012
Thanks Given: 8
Thanks Received: 107


Dan46 View Post
hi mwtzzz, I think I can exclude that the different levels the TS buys are due to better price fills because it happens for example that the TS buys few candles after the candle that closed under the theoretical price to buy..

example: the TS bought at 130, next theoretical price to buy is 100
it happens that there are candles that close at let's say 95 and the TS still don't buys the next contract...

(sorry for my bad english)

If you're trying to add to existing position, be sure to enable "pyramiding orders" in Format Strategies > Properties for All.

also use some "Print()" statements for debugging. You can Print the entrylevel and currentshares to make sure it's doing what it should be

Reply With Quote
(login for full post details)
  #6 (permalink)
 bomberone1 
London
 
Experience: Beginner
Platform: MultiCharts
Posts: 277 since Nov 2010
Thanks Given: 14
Thanks Received: 29

Do you find a solution?

Reply With Quote
(login for full post details)
  #7 (permalink)
OMEGAA
milan italy
 
Posts: 7 since Nov 2022
Thanks Given: 0
Thanks Received: 0

Do you want to enter every time the price drops by X points and close all positions once it touches the moving average line?

Reply With Quote





NexusFi Trading Community Platforms and Indicators EasyLanguage Programming > TS with grid orders in EasyLanguage


Last Updated on July 6, 2023


© 2023 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