NexusFi: Find Your Edge


Home Menu

 





How to Backtest PriceAverage Crossove


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
apollo23
Singapore
 
Posts: 12 since Feb 2020
Thanks Given: 4
Thanks Received: 2

Hi

Found PriceAverageCrossover study in TOS but how do i simulate a buy and sell using this strategy? As it is, the Profit and Loss graph is not showing anything.

Am seeing the arrow signal on the chart but hope to improve it further. These are my thoughts.




Entry:

Previous Open of price must be below moving average and today open is above moving average

Exit Option 1:

Price close below moving average

Exit Option 2:

Price had increase say 30% from entry.

Can anybody help ? Below is the script:

 
Code
#
# TD Ameritrade IP Company, Inc. (c) 2009-2020
#

#wizard input: price
#wizard text: crosses
#wizard input: crossingType
#wizard input: averageType
#wizard text: Inputs: length:
#wizard input: length

input price = close;
input length = 15;
input averageType = AverageType.Simple;
input crossingType = {default above, below};

def avg = MovingAverage(averageType, price, length);

plot signal = crosses(price, avg, crossingType == CrossingType.above);

signal.DefineColor("Above", GetColor(6));
signal.DefineColor("Below", GetColor(7));
signal.AssignValueColor(if crossingType == CrossingType.above then signal.color("Above") else signal.color("Below"));

signal.SetPaintingStrategy(if crossingType == CrossingType.above
    then PaintingStrategy.BOOLEAN_ARROW_UP
    else PaintingStrategy.BOOLEAN_ARROW_DOWN);
Thanks


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trump Lands in Beijing on CPI Day: Iran Peace Expires To …
Prediction Markets & Event Contracts
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
Friday Update: Markets Now Pricing Fed Rate HIKES as Sta …
Traders Hideout
Thanks Mike. Godspeed.
The Elite Circle
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #2 (permalink)
VanDriver
Jackson, MS
 
Posts: 34 since Dec 2015
Thanks Given: 1
Thanks Received: 5

The example you gave is of an indicator in the studies section. Studies only slow plots. Open the strategies section and modify the moving average crossover or similar strategy. Strategies will plot entry and exit signals. They will also show a p&l graph.


Reply With Quote




Last Updated on May 16, 2020


© 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