NexusFi: Find Your Edge


Home Menu

 





MultiCharts Coding Help


Discussion in MultiCharts

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




 
Search this Thread
  #1 (permalink)
 
vitrader's Avatar
 vitrader 
New York, New York, United States
 
Experience: Beginner
Platform: TOS
Trading: Options
Posts: 53 since Jul 2015
Thanks Given: 13
Thanks Received: 7

Below is my code for Multicharts:
--
inputs: UpColor(Green), DnColor(Red), BarWidth(1) , CompBars(5) , start.time(0930) , end.time(1600);

vars: haClose(0), haOpen(0), color(0);

if BarNumber = 1 then
begin
haOpen = open;
haClose = (O+H+L+C)/4;
end;

if BarNumber > 1 then
begin
haClose = (O+H+L+C)/4;
haOpen = (haOpen [1] + haClose [1])/2 ;
end;
{ ................................................................................ }
if haClose > haOpen then color = UpColor
else color = DnColor;

for value1 = 1 to CompBars
begin
if haOpen <= MaxList(haOpen[value1],haClose[value1]) and
haOpen >= MinList(haOpen[value1],haClose[value1]) and
haClose <= MaxList(haOpen[value1],haClose[value1]) and
haClose >= MinList(haOpen[value1],haClose[value1]) then
color = color[value1];
end;
{ ................................................................................ }

{plotPB(haOpen,haClose,"heikin-ashi",color);
plotPB(High,Low,"heikin-ashi",color);
SetPlotWidth(1,BarWidth);
SetPlotColor(1,color);
end;}
{ ................................................................................ }

//initial beginning
If time >= start.time and time <= end.time and MarketPosition = 0 then begin

//long entry
if haClose > haOpen then begin
Buy 100 shares next bar at Market;
If MarketPosition = 1 and haClose < haOpen then begin
Sell ("close") 100 shares next bar at Market;
End;
end;

//short entry
if haClose < haOpen then begin
Sellshort ("enter short") 100 shares next bar at Market;
if MarketPosition = -1 and haClose > haOpen then begin
buytocover ("close") 100 shares next bar at Market;
end;
end;
End;
--
For some reason, the code isn't executing orders despite it being compiled successfully. If anyone can offer any help, it would be greatly appreciated.

Thank you.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
Q1 2026 Shatters All Derivatives Volume Records -- CME H …
Traders Hideout
White House Drops First Alien Files Today -- Market Says …
Prediction Markets & Event Contracts
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
The May 31 Binary: 60% Trump Declares Iran Ops Over, Onl …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
The Pivot Point 113.6³ — Navigating the Prediction of …
26 thanks
Sober Journey With S&P
16 thanks
The Confluence Meter: A Multi-Layered Signal Framework B …
11 thanks
NT8 color choices
10 thanks
Volume Indicators
7 thanks
  #2 (permalink)
 
sptrader's Avatar
 sptrader 
Colorado
 
Experience: Advanced
Platform: MultiCharts
Broker: IB & Iqfeed
Trading: ES , CL
Posts: 535 since Apr 2010
Thanks Given: 1,097
Thanks Received: 702

You have MarketPosition = 0 as a condition , so once you open a position, it will never close or take another position..


Reply With Quote
Thanked by:
  #3 (permalink)
 
vitrader's Avatar
 vitrader 
New York, New York, United States
 
Experience: Beginner
Platform: TOS
Trading: Options
Posts: 53 since Jul 2015
Thanks Given: 13
Thanks Received: 7



sptrader View Post
You have MarketPosition = 0 as a condition , so once you open a position, it will never close or take another position..

Thank you.


Started this thread Reply With Quote




Last Updated on April 21, 2016


© 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