NexusFi: Find Your Edge


Home Menu

 





Preventing limit orders to be taken at the same price on the next bar


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
thinkorn00b
stavanger
 
Posts: 19 since Sep 2020
Thanks Given: 1
Thanks Received: 1

I have a code that takes multiple limit orders over several bars. The problem is that it doesn't store the entry price of the orders that executes, so it takes the same limit order on the next bar, instead of taking a lower limit order, or neglect the limit order if it doesn't come down the price.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Hormuz Completely Closed: US Strikes Day 2, Iran Shoots …
Traders Hideout
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
The June 15 Resolution Trap: Irans Agreed Text Still Pri …
Prediction Markets & Event Contracts
Hormuz Normalization Collapses to 19.5% -- Iran Regime F …
Prediction Markets & Event Contracts
Thursday May 28: GDP + Core PCE + Jobless Claims All at …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
abev
seattle washington
 
Posts: 75 since Feb 2019
Thanks Given: 11
Thanks Received: 30

Nope, the strategy does not store the entry price unless you create a variable for it, store the value to the variable, and query the value of the variable to compare it to the potentially new entry price. lol - yeah you have some additional code to create to make it work.


Reply With Quote
  #3 (permalink)
thinkorn00b
stavanger
 
Posts: 19 since Sep 2020
Thanks Given: 1
Thanks Received: 1


Hi, thanks for the answer. Yes I know it doesn't store the price. However I got it to work by checking the number of contracts that the strategy have taken, and then disabling the limit prices based on that. Ex:

 
Code
if currentcontracts = 0 then
begin
    EntryLimit1 = true;
    EntryLimit2 = true;
    EntryLimit3 = true;
    EntryLimit4 = true;
 end
else if currentcontracts = 1 then
begin
    EntryLimit1 = false;
    EntryLimit2 = true;
    EntryLimit3 = true;
    EntryLimit4 = true;
end
else if currentcontracts = 2 then
begin
    EntryLimit1 = false;
    EntryLimit2 = false;
    EntryLimit3 = true;
    EntryLimit4 = true;
end
else if currentcontracts = 3 then
begin
    EntryLimit1 = false;
    EntryLimit2 = false;
    EntryLimit3 = false;
    EntryLimit4 = true;
end;
end;

if entrysignal then
begin
    if EntryLimit1 then Buy("BuyLimit1") 1 contract next bar at PivotLowPrice * (1 + (EntryPercentageAbovePivotLow * 0.0001)) limit;
    if EntryLimit2 then Buy("BuyLimit2") 1 contract next bar at PivotLowPrice * (1 + (EntryPercentageAbovePivotLow * 0.00008)) limit;
    if EntryLimit3 then Buy("BuyLimit3") 1 contract next bar at PivotLowPrice * (1 + (EntryPercentageAbovePivotLow * 0.00006)) limit;
    if EntryLimit4 then Buy("BuyLimit4") 1 contract next bar at PivotLowPrice * (1 + (EntryPercentageAbovePivotLow * 0.00004)) limit;
end;


Reply With Quote
  #4 (permalink)
abev
seattle washington
 
Posts: 75 since Feb 2019
Thanks Given: 11
Thanks Received: 30

Nice! I'd not have thought of doing it that way but I like it -- simple and straight forward.


Reply With Quote




Last Updated on April 27, 2023


© 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